package com.wbdgj.ui.mine;

import android.content.Context;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.wbdgj.R;
import com.wbdgj.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class PointShopActivity extends BaseActivity{

    private Context context = this;

    @BindView(R.id.destination_tab_layout)
    TabLayout mTabLayout;
    @BindView(R.id.destination_viewpager)
    ViewPager mViewPager;

    private MyFragmentPagerAdapter adapter;
    private List<Fragment> fragments;
    private Shop01Fragment Shop01Fragment;

    @Override
    protected int getLayoutResId() {
        return R.layout.ui_point_shop_detail;
    }

    @Override
    protected void initView() {
        fragments = new ArrayList<>();
        fragments.add(Shop01Fragment = (Shop01Fragment) Fragment.instantiate(context,Shop01Fragment.class.getName()));
        fragments.add(Shop01Fragment = (Shop01Fragment) Fragment.instantiate(context,Shop01Fragment.class.getName()));
        fragments.add(Shop01Fragment = (Shop01Fragment) Fragment.instantiate(context,Shop01Fragment.class.getName()));
        fragments.add(Shop01Fragment = (Shop01Fragment) Fragment.instantiate(context,Shop01Fragment.class.getName()));
        adapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
        mViewPager.setAdapter(adapter);
        mTabLayout.setupWithViewPager(mViewPager);
        mTabLayout.getTabAt(0).setText("精选");
        mTabLayout.getTabAt(1).setText("优惠券");
        mTabLayout.getTabAt(2).setText("游戏皮肤");
        mTabLayout.getTabAt(3).setText("实物奖品");
    }
    private class MyFragmentPagerAdapter extends FragmentPagerAdapter {
        public MyFragmentPagerAdapter(FragmentManager fm) {
            super(fm);

        }
        @Override
        public Fragment getItem(int position) {
            return fragments.get(position);
        }

        @Override
        public int getCount() {
            return fragments.size();
        }
    }

}
